package com.product.easyExcel;



import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @description: DemoDataListener
 * @date: 2021/3/26
 * @author: 王瑾
 */
public class ExcelListener extends AnalysisEventListener {

    /**
     * @description 用于保存数据
     * @author 王瑾
     * @param null
     * @return
     */
    public static List<Object> datas = Collections.synchronizedList(new ArrayList<>());

    /**
     * @description
     * @author 王瑾
     * @param o 读取的每行数据
     * @param analysisContext
     * @return void
     */
    @Override
    public void invoke(Object o, AnalysisContext analysisContext) {
        // 追加check
        datas.add(o);
    }

    /**
     * @description excel 读取完之后的操作
     * @author 王瑾
     * @param analysisContext
     * @return void
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

//        analysisContext.
    }

    public static List<Object> getDatas() {
        return datas;
    }

    public void setDatas(List<Object> datas) {
        ExcelListener.datas = datas;
    }
}
